home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / microcrn / issue_45.arc / 86WRLD45.ARC / 86WRLD45.1 next >
Text File  |  1988-03-23  |  948b  |  44 lines

  1. ; 86WORLD Figure 1  Micro Cornucopia Magazine Issue #45
  2. ; First Version of Fact, Passing Result in AX
  3.  
  4.  
  5.         .MODEL SMALL,PASCAL
  6.         .286c
  7.  
  8. CALLS   MACRO   Routine, Parameters
  9.   IRP   Param,<Parameters>
  10.     IF  (((.TYPE Param) AND 4) AND ((@Cpu AND 2) EQ 0))
  11.         MOV     AX,Param        ;constants cannot be directly
  12.         PUSH    AX              ;pushed on cpu's below 186
  13.     ELSE
  14.         PUSH    Param
  15.     ENDIF
  16.   ENDM
  17.         CALL    Routine
  18. ENDM
  19.  
  20.         .STACK  1024
  21.         .CODE
  22. Fact    PROC    NEAR USES BX, Number:WORD
  23.         CMP     Number,1
  24.         JNE     @F
  25.         MOV     AX,1
  26.         JMP     Fact99
  27. @@:     MOV     BX,Number
  28.         DEC     BX
  29.         CALLS   Fact,<BX>
  30.         ADD     AX,Number
  31. Fact99: RET
  32. Fact    ENDP
  33.  
  34. MAIN    PROC    NEAR
  35.         CALLS   Fact,<5>        ;returns fact(5) in AX
  36.         MOV     AX,4C00h
  37.         INT     21h
  38. MAIN    ENDP
  39.  
  40. END     MAIN
  41.  
  42.  
  43.  
  44.